package com.huanwei.read.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.huanwei.cc.base.Base_Z_Adapter;
import com.huanwei.cc.base.MyApplication;
import com.huanwei.cc.R;
import com.huanwei.cc.bean.DYD_Beam;
import com.huanwei.cc.bean.XinWen;
import com.huanwei.cc.utils.UILUtils;

import java.text.SimpleDateFormat;
import java.util.Date;




/**
 * Created by 他的猫 on 2016/11/21.
 * 全部订单适配器
 */

public class Meir_Adapter extends Base_Z_Adapter {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Meir_Adapter.Holder holder = null;
        // 查找控件
        if (null == convertView) {
            convertView = LayoutInflater.from(MyApplication.getInstance())
                    .inflate(R.layout.tab_item_1_buy_5_ywc2, null);
            holder = new Meir_Adapter.Holder();



            holder.tv_smname = (TextView) convertView
                    .findViewById(R.id.tv_smname);
            holder.tv_js = (TextView) convertView
                    .findViewById(R.id.tv_js);
            holder.tv_gg = (TextView) convertView
                    .findViewById(R.id.tv_gg);
            holder.im_photo = (ImageView) convertView
                    .findViewById(R.id.im_photo);

            // 缓存Holder
            convertView.setTag(holder);
        } else {
            holder = (Meir_Adapter.Holder) convertView.getTag();
        }
        XinWen.ResultBean.DataBean rowData = (XinWen.ResultBean.DataBean) getItem(position);

         holder.tv_smname.setText(rowData.getTitle());
         UILUtils.displayImage(rowData.getThumbnail_pic_s() , holder.im_photo);
         holder.tv_gg.setText(rowData.getAuthor_name());
         holder.tv_js.setText( rowData.getDate());
        return convertView;
    }
    /*
     * 将时间戳转换为时间
     */
    public static String stampToDate(String s){
        Date date = null;
        SimpleDateFormat format =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Long time=new Long(s);
        String d = format.format(time);


        return d;
    }
    public class Holder {

        TextView tv_names;
        TextView tv_wpyf;
        TextView tv_smname;
        TextView tv_ze;
        TextView tv_dj;
        TextView tv_js;
        TextView tv_gg;
        TextView tv_money;
        ImageView im_photo;
    }
}
